<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="./lib/bootstrap3.3.7.css">
    <script src="./lib/moment.2.24.0.js"></script>
    <script src="./lib/vue2.4.4.js"></script>
</head>

<body>
    <h1>参考： <a href="https://cn.vuejs.org/v2/guide/filters.html">https://cn.vuejs.org/v2/guide/filters.html</a> 官方文档</h1>
    <div id="app">
        <p>{{msg | translate('疯狂')}}</p>
    </div>

    <script>
        var FORMAT_TIME_STR = 'YYYY-MM-DD HH:mm:ss';
        var vm = new Vue({
            el: '#app',
            data: {
                msg: '曾经，我也是一个单纯的少年，单纯的我，傻傻的问，谁是世界上最单纯的男人'
            },
            methods: {
            },
            filters: {
                translate(val, val2) {
                    if (val.includes('单纯')) {
                        return val.replace(/单纯/gi, val2);
                    }
                    return val;
                }
            }
        });
    </script>
</body>

</html>